/**
 * Created by python on 18-11-9.
 */

// 字符串转日期
Vue.filter('str_date',function (date) {
    return new Date(date)
});

//　日期获得年月日
Vue.filter('date_ymd',function (date) {
    return date.getFullYear()+'-'+(date.getUTCMonth()+1)+'-'+date.getUTCDate()
});

//　日期获得十分秒
Vue.filter('date_hms',function (date) {
    return date.getUTCHours()+':'+date.getUTCMinutes()+':'+date.getUTCSeconds()
});

//　获得周
const WEEK = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
Vue.filter('date_w',function (date) {
    return WEEK[date.getDay()]
});


// 获取url路径参数
function get_query_string(name){
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return decodeURI(r[2]);
    }
    return null;
}




var host = "http://127.0.0.1:8000";

var static_url = 'http://127.0.0.1:8000/static/';


Vue.filter('str2date', function(date_str) {
    return new Date(date_str)
});

Vue.filter('date2ymd', function(date) {
    return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate()
});

Vue.filter('date2hm', function(date) {
    return ("0" + date.getHours()).slice(-2) + ":" + ("0" + date.getMinutes()).slice(-2)
});

const week=['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
Vue.filter('date2w', function(date) {
    return week[date.getDay()]
});